package com.winterchen.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.winterchen.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {
	@Value("${mybatis.mapper-locations1}")
	private String testMsg;
	@Autowired
    private UserService userService;

    @ResponseBody
    @PostMapping("/add")
    public int addUser(Map user){
        return userService.addUser(user);
    }

    @ResponseBody
    @RequestMapping(value = "/all" , method = RequestMethod.POST)
    public Object findAllUser(
            @RequestParam(name = "pageNum", required = false, defaultValue = "1")
                    int pageNum,
            @RequestParam(name = "pageSize", required = false, defaultValue = "10")
                    int pageSize){
        PageInfo<Map> findAllUser = userService.findAllUser(pageNum,pageSize);
        return findAllUser;
    }
}
